if exists(select * from sys.databases db where db.name = 'AssStructs')
use master
go
drop database AssStructs
go
create database AssStructs
go
use AssStructs
go
create table account(
	AccountNo nvarchar(20),
	Password nvarchar(50),
	Balance int,
	primary key (AccountNo)
)
go
create table Transactions(
	Id int identity(1,1),
	AccountNo nvarchar(20),
	Date datetime,
	TypeTransact char(3),
	Amount int,
	primary key (Id),
	foreign key (AccountNo) references account(AccountNo)
)
---------------
go
create proc AddAccount
	@AccountNo nvarchar(20),
	@Password nvarchar(50),
	@Balance int
as
	insert into Account (AccountNo,Password,Balance)
		values (@AccountNo,HashBytes('MD5',@Password),@Balance)
go
create proc CheckAccount
	@AccountNo nvarchar(20),
	@Password nvarchar(50)
as 
	select * from Account where AccountNo = @AccountNo and Password = HashBytes('MD5',@Password)
go
create proc DoTransact
	@AccountNo nvarchar(20),
	@TypeTransact char(3),
	@Amount int
as
	insert into Transactions values (@AccountNo,getdate(),@TypeTransact,@Amount)
go

create proc ListTransact
	@AccountNo nvarchar(20)
as
	select * from Transactions where AccountNo = @AccountNo
go